﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Diagnostics;  

namespace LinSM
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            //Application.EnableVisualStyles();
            //Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new Login());
            System.Threading.Mutex mutex = new System.Threading.Mutex(false, "ThisShouldOnlyRunOnce");
            bool Running = !mutex.WaitOne(0, false);
            if (!Running)
            {
                //Login f1 = new Login();
                //GiveClan f1 = new GiveClan();
                //Characters f1 = new Characters();
                //Form1 f1 = new Form1();
                //Link f1 = new Link();
                Main f1 = new Main();
                //Shop f1 = new Shop();
                //AllItem f1 = new AllItem();

                f1.Show();
                Application.Run();
            }
            else
            {
                Process[] ps = Process.GetProcesses();
                foreach (System.Diagnostics.Process p in ps)
                {
                    //如果进程为LinSM，则关闭进程   
                    if (p.ProcessName == "LinSM")
                    {
                        p.Kill();
                        break;
                    }
                }
                MessageBox.Show("程序已启动！");
                Application.Run(new Login());
            }
        }
    }
}
